home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / xemacs.info-14 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  50.0 KB  |  1,215 lines

  1. This is Info file ../../info/xemacs.info, produced by Makeinfo-1.63
  2. from the input file xemacs.texi.
  3.  
  4.    This file documents the XEmacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  7. 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
  8. Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided also
  16. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  17. General Public License" are included exactly as in the original, and
  18. provided that the entire resulting derived work is distributed under the
  19. terms of a permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that the sections entitled "The GNU Manifesto",
  24. "Distribution" and "GNU General Public License" may be included in a
  25. translation approved by the author instead of in the original English.
  26.  
  27. 
  28. File: xemacs.info,  Node: Shell Mode,  Next: Terminal emulator,  Prev: Interactive Shell,  Up: Shell
  29.  
  30. Shell Mode
  31. ----------
  32.  
  33.    The shell buffer uses Shell mode, which defines several special keys
  34. attached to the `C-c' prefix.  They are chosen to resemble the usual
  35. editing and job control characters present in shells that are not under
  36. XEmacs, except that you must type `C-c' first.  Here is a list of the
  37. special key bindings of Shell mode:
  38.  
  39. `RET'
  40.      At end of buffer send line as input; otherwise, copy current line
  41.      to end of buffer and send it (`send-shell-input').  When a line is
  42.      copied, any text at the beginning of the line that matches the
  43.      variable `shell-prompt-pattern' is left out; this variable's value
  44.      should be a regexp string that matches the prompts that you use in
  45.      your subshell.
  46.  
  47. `C-c C-d'
  48.      Send end-of-file as input, probably causing the shell or its
  49.      current subjob to finish (`shell-send-eof').
  50.  
  51. `C-d'
  52.      If point is not at the end of the buffer, delete the next
  53.      character just like most other modes.  If point is at the end of
  54.      the buffer, send end-of-file as input, instead of generating an
  55.      error as in other modes (`comint-delchar-or-maybe-eof').
  56.  
  57. `C-c C-u'
  58.      Kill all text that has yet to be sent as input
  59.      (`kill-shell-input').
  60.  
  61. `C-c C-w'
  62.      Kill a word before point (`backward-kill-word').
  63.  
  64. `C-c C-c'
  65.      Interrupt the shell or its current subjob if any
  66.      (`interrupt-shell-subjob').
  67.  
  68. `C-c C-z'
  69.      Stop the shell or its current subjob if any (`stop-shell-subjob').
  70.  
  71. `C-c C-\'
  72.      Send quit signal to the shell or its current subjob if any
  73.      (`quit-shell-subjob').
  74.  
  75. `C-c C-o'
  76.      Delete last batch of output from shell (`kill-output-from-shell').
  77.  
  78. `C-c C-r'
  79.      Scroll top of last batch of output to top of window
  80.      (`show-output-from-shell').
  81.  
  82. `C-c C-y'
  83.      Copy the previous bunch of shell input and insert it into the
  84.      buffer before point (`copy-last-shell-input').  No final newline
  85.      is inserted, and the input copied is not resubmitted until you type
  86.      RET.
  87.  
  88. `M-p'
  89.      Move backward through the input history.  Search for a matching
  90.      command if you have typed the beginning of a command
  91.      (`comint-previous-input').
  92.  
  93. `M-n'
  94.      Move forward through the input history.  Useful when you are using
  95.      M-p quickly and go past the desired command (`comint-next-input').
  96.  
  97. `TAB'
  98.      Complete the file name preceding point (`comint-dynamic-complete').
  99.  
  100. 
  101. File: xemacs.info,  Node: Terminal emulator,  Next: Term Mode,  Prev: Shell Mode,  Up: Shell
  102.  
  103. Interactive Inferior Shell with Terminal Emulator
  104. -------------------------------------------------
  105.  
  106.    To run a subshell in a terminal emulator, putting its typescript in
  107. an XEmacs buffer, use `M-x term'.  This creates (or reuses) a buffer
  108. named `*term*' and runs a subshell with input coming from your keyboard
  109. and output going to that buffer.
  110.  
  111.    All the normal keys that you type are sent without any interpretation
  112. by XEmacs directly to the subshell, as "terminal input." Any "echo" of
  113. your input is the responsibility of the subshell.  (The exception is
  114. the terminal escape character, which by default is `C-c'. *note Term
  115. Mode::..) Any "terminal output" from the subshell goes into the buffer,
  116. advancing point.
  117.  
  118.    Some programs (such as XEmacs itself) need to control the appearance
  119. on the terminal screen in detail.  They do this by sending special
  120. control codes.  The exact control codes needed vary from terminal to
  121. terminal, but nowadays most terminals and terminal emulators (including
  122. xterm) understand the so-called "ANSI escape sequences" (first
  123. popularized by the Digital's VT100 family of terminal).  The term mode
  124. also understands these escape sequences, and for each control code does
  125. the appropriate thing to change the buffer so that the appearance of
  126. the window will match what it would be on a real terminal.  Thus you
  127. can actually run XEmacs inside an XEmacs Term window!
  128.  
  129.    XEmacs does not wait for the subshell to do anything.  You can switch
  130. windows or buffers and edit them while the shell is waiting, or while
  131. it is running a command.  Output from the subshell waits until XEmacs
  132. has time to process it; this happens whenever XEmacs is waiting for
  133. keyboard input or for time to elapse.
  134.  
  135.    To make multiple terminal emulators, rename the buffer `*term*' to
  136. something different using `M-x rename-uniquely', just as with Shell
  137. mode.
  138.  
  139.    The file name used to load the subshell is determined the same way
  140. as for Shell mode.
  141.  
  142.    Unlike Shell mode, Term mode does not track the current directory by
  143. examining your input.  Instead, if you use a programmable shell, you
  144. can have it tell Term what the current directory is.  This is done
  145. automatically by bash for version 1.15 and later.
  146.  
  147. 
  148. File: xemacs.info,  Node: Term Mode,  Next: Paging in Term,  Prev: Terminal emulator,  Up: Shell
  149.  
  150. Term Mode
  151. ---------
  152.  
  153.    Term uses Term mode, which has two input modes: In line mode, Term
  154. basically acts like Shell mode.  *Note Shell Mode::.  In Char mode,
  155. each character is sent directly to the inferior subshell, except for
  156. the Term escape character, normally `C-c'.
  157.  
  158.    To switch between line and char mode, use these commands:
  159.      findex term-char-mode
  160.  
  161. `C-c C-k'
  162.      Switch to line mode.  Do nothing if already in line mode.
  163.  
  164. `C-c C-j'
  165.      Switch to char mode.  Do nothing if already in char mode.
  166.  
  167.    The following commands are only available in Char mode:
  168. `C-c C-c'
  169.      Send a literal C-c to the sub-shell.
  170.  
  171. `C-c C-x'
  172.      A prefix command to conveniently access the global C-x commands.
  173.      For example, `C-c C-x o' invokes the global binding of `C-x o',
  174.      which is normally `other-window'.
  175.  
  176. 
  177. File: xemacs.info,  Node: Paging in Term,  Prev: Term Mode,  Up: Shell
  178.  
  179. Paging in the terminal emulator
  180. -------------------------------
  181.  
  182.    Term mode has a pager feature.  When the pager is enabled, term mode
  183. will pause at the end of each screenful.
  184.  
  185. `C-c C-q'
  186.      Toggles the pager feature:  Disables the pager if it is enabled,
  187.      and vice versa.  This works in both line and char modes.  If the
  188.      pager enabled, the mode-line contains the word `page'.
  189.  
  190.    If the pager is enabled, and Term receives more than a screenful of
  191. output since your last input, Term will enter More break mode.  This is
  192. indicated by `**MORE**' in the mode-line.  Type a `Space' to display
  193. the next screenful of output.  Type `?' to see your other options.  The
  194. interface is similar to the Unix `more' program.
  195.  
  196. 
  197. File: xemacs.info,  Node: Narrowing,  Next: Hardcopy,  Prev: Shell,  Up: Top
  198.  
  199. Narrowing
  200. =========
  201.  
  202.    "Narrowing" means focusing in on some portion of the buffer, making
  203. the rest temporarily invisible and inaccessible.  Cancelling the
  204. narrowing and making the entire buffer once again visible is called
  205. "widening".  The amount of narrowing in effect in a buffer at any time
  206. is called the buffer's "restriction".
  207.  
  208. `C-x n n'
  209.      Narrow down to between point and mark (`narrow-to-region').
  210.  
  211. `C-x n w'
  212.      Widen to make the entire buffer visible again (`widen').
  213.  
  214.    Narrowing sometimes makes it easier to concentrate on a single
  215. subroutine or paragraph by eliminating clutter.  It can also be used to
  216. restrict the range of operation of a replace command or repeating
  217. keyboard macro.  The word `Narrow' appears in the mode line whenever
  218. narrowing is in effect.  When you have narrowed to a part of the
  219. buffer, that part appears to be all there is.  You can't see the rest,
  220. can't move into it (motion commands won't go outside the visible part),
  221. and can't change it in any way.  However, the invisible text is not
  222. gone; if you save the file, it will be saved.
  223.  
  224.    The primary narrowing command is `C-x n n' (`narrow-to-region').  It
  225. sets the current buffer's restrictions so that the text in the current
  226. region remains visible but all text before the region or after the
  227. region is invisible.  Point and mark do not change.
  228.  
  229.    Because narrowing can easily confuse users who do not understand it,
  230. `narrow-to-region' is normally a disabled command.  Attempting to use
  231. this command asks for confirmation and gives you the option of enabling
  232. it; once you enable the command, confirmation will no longer be
  233. required.  *Note Disabling::.
  234.  
  235.    To undo narrowing, use `C-x n w' (`widen').  This makes all text in
  236. the buffer accessible again.
  237.  
  238.    Use the `C-x =' command to get information on what part of the
  239. buffer you narrowed down.  *Note Position Info::.
  240.  
  241. 
  242. File: xemacs.info,  Node: Hardcopy,  Next: Recursive Edit,  Prev: Narrowing,  Up: Top
  243.  
  244. Hardcopy Output
  245. ===============
  246.  
  247.    The XEmacs commands for making hardcopy derive their names from the
  248. Unix commands `print' and `lpr'.
  249.  
  250. `M-x print-buffer'
  251.      Print hardcopy of current buffer using Unix command `print'
  252.      (`lpr -p').  This command adds page headings containing the file
  253.      name and page number.
  254.  
  255. `M-x lpr-buffer'
  256.      Print hardcopy of current buffer using Unix command `lpr'.  This
  257.      command does not add page headings.
  258.  
  259. `M-x print-region'
  260.      Like `print-buffer', but prints only the current region.
  261.  
  262. `M-x lpr-region'
  263.      Like `lpr-buffer', but prints only the current region.
  264.  
  265.    All the hardcopy commands pass extra switches to the `lpr' program
  266. based on the value of the variable `lpr-switches'.  Its value should be
  267. a list of strings, each string a switch starting with `-'.  For
  268. example, the value could be `("-Pfoo")' to print on printer `foo'.
  269.  
  270. 
  271. File: xemacs.info,  Node: Recursive Edit,  Next: Dissociated Press,  Prev: Hardcopy,  Up: Top
  272.  
  273. Recursive Editing Levels
  274. ========================
  275.  
  276.    A "recursive edit" is a situation in which you are using XEmacs
  277. commands to perform arbitrary editing while in the middle of another
  278. XEmacs command.  For example, when you type `C-r' inside a
  279. `query-replace', you enter a recursive edit in which you can change the
  280. current buffer.  When you exit from the recursive edit, you go back to
  281. the `query-replace'.
  282.  
  283.    "Exiting" a recursive edit means returning to the unfinished
  284. command, which continues execution.  For example, exiting the recursive
  285. edit requested by `C-r' in `query-replace' causes query replacing to
  286. resume.  Exiting is done with `C-M-c' (`exit-recursive-edit').
  287.  
  288.    You can also "abort" a recursive edit.  This is like exiting, but
  289. also quits the unfinished command immediately.  Use the command `C-]'
  290. (`abort-recursive-edit') for this.  *Note Quitting::.
  291.  
  292.    The mode line shows you when you are in a recursive edit by
  293. displaying square brackets around the parentheses that always surround
  294. the major and minor mode names.  Every window's mode line shows the
  295. square brackets, since XEmacs as a whole, rather than any particular
  296. buffer, is in a recursive edit.
  297.  
  298.    It is possible to be in recursive edits within recursive edits.  For
  299. example, after typing `C-r' in a `query-replace', you might type a
  300. command that entered the debugger.  In such a case, two or more sets of
  301. square brackets appear in the mode line(s).  Exiting the inner
  302. recursive edit (here with the debugger `c' command) resumes the
  303. query-replace command where it called the debugger.  After the end of
  304. the query-replace command, you would be able to exit the first
  305. recursive edit.  Aborting exits only one level of recursive edit; it
  306. returns to the command level of the previous recursive edit.  You can
  307. then abort that one as well.
  308.  
  309.    The command `M-x top-level' aborts all levels of recursive edits,
  310. returning immediately to the top level command reader.
  311.  
  312.    The text you edit inside the recursive edit need not be the same text
  313. that you were editing at top level.  If the command that invokes the
  314. recursive edit selects a different buffer first, that is the buffer you
  315. will edit recursively.  You can switch buffers within the recursive edit
  316. in the normal manner (as long as the buffer-switching keys have not been
  317. rebound).  While you could theoretically do the rest of your editing
  318. inside the recursive edit, including visiting files, this could have
  319. surprising effects (such as stack overflow) from time to time.  It is
  320. best if you always exit or abort a recursive edit when you no longer
  321. need it.
  322.  
  323.    In general, XEmacs tries to avoid using recursive edits.  It is
  324. usually preferable to allow users to switch among the possible editing
  325. modes in any order they like.  With recursive edits, the only way to get
  326. to another state is to go "back" to the state that the recursive edit
  327. was invoked from.
  328.  
  329. 
  330. File: xemacs.info,  Node: Dissociated Press,  Next: CONX,  Prev: Recursive Edit,  Up: Top
  331.  
  332. Dissociated Press
  333. =================
  334.  
  335.    `M-x dissociated-press' is a command for scrambling a file of text
  336. either word by word or character by character.  Starting from a buffer
  337. of straight English, it produces extremely amusing output.  The input
  338. comes from the current XEmacs buffer.  Dissociated Press writes its
  339. output in a buffer named `*Dissociation*', and redisplays that buffer
  340. after every couple of lines (approximately) to facilitate reading it.
  341.  
  342.    `dissociated-press' asks every so often whether to continue
  343. operating.  Answer `n' to stop it.  You can also stop at any time by
  344. typing `C-g'.  The dissociation output remains in the `*Dissociation*'
  345. buffer for you to copy elsewhere if you wish.
  346.  
  347.    Dissociated Press operates by jumping at random from one point in the
  348. buffer to another.  In order to produce plausible output rather than
  349. gibberish, it insists on a certain amount of overlap between the end of
  350. one run of consecutive words or characters and the start of the next.
  351. That is, if it has just printed out `president' and then decides to
  352. jump to a different point in the file, it might spot the `ent' in
  353. `pentagon' and continue from there, producing `presidentagon'.  Long
  354. sample texts produce the best results.
  355.  
  356.    A positive argument to `M-x dissociated-press' tells it to operate
  357. character by character, and specifies the number of overlap characters.
  358. A negative argument tells it to operate word by word and specifies the
  359. number of overlap words.  In this mode, whole words are treated as the
  360. elements to be permuted, rather than characters.  No argument is
  361. equivalent to an argument of two.  For your againformation, the output
  362. goes only into the buffer `*Dissociation*'.  The buffer you start with
  363. is not changed.
  364.  
  365.    Dissociated Press produces nearly the same results as a Markov chain
  366. based on a frequency table constructed from the sample text.  It is,
  367. however, an independent, ignoriginal invention.  Dissociated Press
  368. techniquitously copies several consecutive characters from the sample
  369. between random choices, whereas a Markov chain would choose randomly for
  370. each word or character.  This makes for more plausible sounding results
  371. and runs faster.
  372.  
  373.    It is a mustatement that too much use of Dissociated Press can be a
  374. developediment to your real work.  Sometimes to the point of outragedy.
  375. And keep dissociwords out of your documentation, if you want it to be
  376. well userenced and properbose.  Have fun.  Your buggestions are welcome.
  377.  
  378. 
  379. File: xemacs.info,  Node: CONX,  Next: Amusements,  Prev: Dissociated Press,  Up: Top
  380.  
  381. CONX
  382. ====
  383.  
  384.    Besides producing a file of scrambled text with Dissociated Press,
  385. you can generate random sentences by using CONX.
  386.  
  387. `M-x conx'
  388.      Generate random sentences in the `*conx*' buffer.
  389.  
  390. `M-x conx-buffer'
  391.      Absorb the text in the current buffer into the `conx' database.
  392.  
  393. `M-x conx-init'
  394.      Forget the current word-frequency tree.
  395.  
  396. `M-x conx-load'
  397.      Load a `conx' database that has been previously saved with `M-x
  398.      conx-save'.
  399.  
  400. `M-x conx-region'
  401.      Absorb the text in the current buffer into the `conx' database.
  402.  
  403. `M-x conx-save'
  404.      Save the current `conx' database to a file for future retrieval.
  405.  
  406.    Copy text from a buffer using `M-x conx-buffer' or `M-x conx-region'
  407. and then type `M-x conx'.  Output is continuously generated until you
  408. type ^G. You can save the `conx' database to a file with `M-x
  409. conx-save', which you can retrieve with `M-x conx-load'.  To clear the
  410. database, use `M-x conx-init'.
  411.  
  412. 
  413. File: xemacs.info,  Node: Amusements,  Next: Emulation,  Prev: CONX,  Up: Top
  414.  
  415. Other Amusements
  416. ================
  417.  
  418.    If you are a little bit bored, you can try `M-x hanoi'.  If you are
  419. considerably bored, give it a numeric argument.  If you are very, very
  420. bored, try an argument of 9.  Sit back and watch.
  421.  
  422.    When you are frustrated, try the famous Eliza program.  Just do `M-x
  423. doctor'.  End each input by typing `RET' twice.
  424.  
  425.    When you are feeling strange, type `M-x yow'.
  426.  
  427. 
  428. File: xemacs.info,  Node: Emulation,  Next: Customization,  Prev: Amusements,  Up: Top
  429.  
  430. Emulation
  431. =========
  432.  
  433.    XEmacs can be programmed to emulate (more or less) most other
  434. editors.  Standard facilities can emulate these:
  435.  
  436. Viper (a vi emulator)
  437.      In XEmacs, Viper is the preferred emulation of vi within XEmacs.
  438.      Viper is designed to allow you to take advantage of the best
  439.      features of XEmacs while still doing your basic editing in a
  440.      familiar, vi-like fashion.  Viper provides various different
  441.      levels of vi emulation, from a quite complete emulation that
  442.      allows almost no access to native XEmacs commands, to an "expert"
  443.      mode that combines the most useful vi commands with the most
  444.      useful XEmacs commands.
  445.  
  446.      To start Viper, put the command
  447.  
  448.           (require 'viper)
  449.  
  450.      in your `.emacs' file.
  451.  
  452.      Viper comes with a separate manual that is provided standard with
  453.      the XEmacs distribution.
  454.  
  455. evi (alternative vi emulator)
  456.      evi is an alternative vi emulator that also provides a nearly
  457.      complete emulation of vi.
  458.  
  459.      evi comes with a separate manual that is provided standard with
  460.      the XEmacs distribution.
  461.  
  462.      Warning: loading more than one vi emulator at once may cause name
  463.      conflicts; no one has checked.
  464.  
  465. EDT (DEC VMS editor)
  466.      Turn on EDT emulation with `M-x edt-emulation-on'.  `M-x
  467.      edt-emulation-off' restores normal Emacs command bindings.
  468.  
  469.      Most of the EDT emulation commands are keypad keys, and most
  470.      standard Emacs key bindings are still available.  The EDT
  471.      emulation rebindings are done in the global keymap, so there is no
  472.      problem switching buffers or major modes while in EDT emulation.
  473.  
  474. Gosling Emacs
  475.      Turn on emulation of Gosling Emacs (aka Unipress Emacs) with `M-x
  476.      set-gosmacs-bindings'.  This redefines many keys, mostly on the
  477.      `C-x' and `ESC' prefixes, to work as they do in Gosmacs.  `M-x
  478.      set-gnu-bindings' returns to normal XEmacs by rebinding the same
  479.      keys to the definitions they had at the time `M-x
  480.      set-gosmacs-bindings' was done.
  481.  
  482.      It is also possible to run Mocklisp code written for Gosling Emacs.
  483.      *Note Mocklisp::.
  484.  
  485. 
  486. File: xemacs.info,  Node: Customization,  Next: Quitting,  Prev: Emulation,  Up: Top
  487.  
  488. Customization
  489. *************
  490.  
  491.    This chapter talks about various topics relevant to adapting the
  492. behavior of Emacs in minor ways.
  493.  
  494.    All kinds of customization affect only the particular Emacs job that
  495. you do them in.  They are completely lost when you kill the Emacs job,
  496. and have no effect on other Emacs jobs you may run at the same time or
  497. later.  The only way an Emacs job can affect anything outside of it is
  498. by writing a file; in particular, the only way to make a customization
  499. `permanent' is to put something in your `.emacs' file or other
  500. appropriate file to do the customization in each session.  *Note Init
  501. File::.
  502.  
  503. * Menu:
  504.  
  505. * Minor Modes::     Each minor mode is one feature you can turn on
  506.                      independently of any others.
  507. * Variables::       Many Emacs commands examine Emacs variables
  508.                      to decide what to do; by setting variables,
  509.                      you can control their functioning.
  510. * Keyboard Macros:: A keyboard macro records a sequence of keystrokes
  511.                      to be replayed with a single command.
  512. * Key Bindings::    The keymaps say what command each key runs.
  513.                      By changing them, you can "redefine keys".
  514. * Syntax::          The syntax table controls how words and expressions
  515.                      are parsed.
  516. * Init File::       How to write common customizations in the `.emacs'
  517.                      file.
  518. * Audible Bell::    Changing how Emacs sounds the bell.
  519. * Faces::           Changing the fonts and colors of a region of text.
  520. * X Resources::        X resources controlling various aspects of the
  521.                      behavior of XEmacs.
  522.  
  523. 
  524. File: xemacs.info,  Node: Minor Modes,  Next: Variables,  Up: Customization
  525.  
  526. Minor Modes
  527. ===========
  528.  
  529.    Minor modes are options which you can use or not.  For example, Auto
  530. Fill mode is a minor mode in which SPC breaks lines between words as
  531. you type.  All the minor modes are independent of each other and of the
  532. selected major mode.  Most minor modes inform you in the mode line when
  533. they are on; for example, `Fill' in the mode line means that Auto Fill
  534. mode is on.
  535.  
  536.    Append `-mode' to the name of a minor mode to get the name of a
  537. command function that turns the mode on or off.  Thus, the command to
  538. enable or disable Auto Fill mode is called `M-x auto-fill-mode'.  These
  539. commands are usually invoked with `M-x', but you can bind keys to them
  540. if you wish.  With no argument, the function turns the mode on if it was
  541. off and off if it was on.  This is known as "toggling".  A positive
  542. argument always turns the mode on, and an explicit zero argument or a
  543. negative argument always turns it off.
  544.  
  545.    Auto Fill mode allows you to enter filled text without breaking lines
  546. explicitly.  Emacs inserts newlines as necessary to prevent lines from
  547. becoming too long.  *Note Filling::.
  548.  
  549.    Overwrite mode causes ordinary printing characters to replace
  550. existing text instead of moving it to the right.  For example, if point
  551. is in front of the `B' in `FOOBAR', and you type a `G' in Overwrite
  552. mode, it changes to `FOOGAR', instead of `FOOGBAR'.
  553.  
  554.    Abbrev mode allows you to define abbreviations that automatically
  555. expand as you type them.  For example, `amd' might expand to `abbrev
  556. mode'.  *Note Abbrevs::, for full information.
  557.  
  558. 
  559. File: xemacs.info,  Node: Variables,  Next: Keyboard Macros,  Prev: Minor Modes,  Up: Customization
  560.  
  561. Variables
  562. =========
  563.  
  564.    A "variable" is a Lisp symbol which has a value.  Variable names can
  565. contain any characters, but by convention they are words separated by
  566. hyphens.  A variable can also have a documentation string, which
  567. describes what kind of value it should have and how the value will be
  568. used.
  569.  
  570.    Lisp allows any variable to have any kind of value, but most
  571. variables that Emacs uses require a value of a certain type.  Often the
  572. value has to be a string or a number.  Sometimes we say that a certain
  573. feature is turned on if a variable is "non-`nil'," meaning that if the
  574. variable's value is `nil', the feature is off, but the feature is on
  575. for any other value.  The conventional value to turn on the
  576. feature--since you have to pick one particular value when you set the
  577. variable--is `t'.
  578.  
  579.    Emacs uses many Lisp variables for internal recordkeeping, as any
  580. Lisp program must, but the most interesting variables for you are the
  581. ones that exist for the sake of customization.  Emacs does not
  582. (usually) change the values of these variables; instead, you set the
  583. values, and thereby alter and control the behavior of certain Emacs
  584. commands.  These variables are called "options".  Most options are
  585. documented in this manual and appear in the Variable Index (*note
  586. Variable Index::.).
  587.  
  588.    One example of a variable which is an option is `fill-column', which
  589. specifies the position of the right margin (as a number of characters
  590. from the left margin) to be used by the fill commands (*note
  591. Filling::.).
  592.  
  593. * Menu:
  594.  
  595. * Examining::           Examining or setting one variable's value.
  596. * Edit Options::        Examining or editing list of all variables' values.
  597. * Locals::              Per-buffer values of variables.
  598. * File Variables::      How files can specify variable values.
  599.  
  600. 
  601. File: xemacs.info,  Node: Examining,  Next: Edit Options,  Up: Variables
  602.  
  603. Examining and Setting Variables
  604. -------------------------------
  605.  
  606. `C-h v'
  607. `M-x describe-variable'
  608.      Print the value and documentation of a variable.
  609.  
  610. `M-x set-variable'
  611.      Change the value of a variable.
  612.  
  613.    To examine the value of a single variable, use `C-h v'
  614. (`describe-variable'), which reads a variable name using the
  615. minibuffer, with completion.  It prints both the value and the
  616. documentation of the variable.
  617.  
  618.      C-h v fill-column RET
  619.  
  620. prints something like:
  621.  
  622.      fill-column's value is 75
  623.      
  624.      Documentation:
  625.      *Column beyond which automatic line-wrapping should happen.
  626.      Automatically becomes local when set in any fashion.
  627.  
  628. The star at the beginning of the documentation indicates that this
  629. variable is an option.  `C-h v' is not restricted to options; it allows
  630. any variable name.
  631.  
  632.    If you know which option you want to set, you can use `M-x
  633. set-variable' to set it.  This prompts for the variable name in the
  634. minibuffer (with completion), and then prompts for a Lisp expression
  635. for the new value using the minibuffer a second time.  For example,
  636.  
  637.      M-x set-variable RET fill-column RET 75 RET
  638.  
  639. sets `fill-column' to 75, as if you had executed the Lisp expression
  640. `(setq fill-column 75)'.
  641.  
  642.    Setting variables in this way, like all means of customizing Emacs
  643. except where explicitly stated, affects only the current Emacs session.
  644.  
  645. 
  646. File: xemacs.info,  Node: Edit Options,  Next: Locals,  Prev: Examining,  Up: Variables
  647.  
  648. Editing Variable Values
  649. -----------------------
  650.  
  651. `M-x list-options'
  652.      Display a buffer listing names, values, and documentation of all
  653.      options.
  654.  
  655. `M-x edit-options'
  656.      Change option values by editing a list of options.
  657.  
  658.    `M-x list-options' displays a list of all Emacs option variables in
  659. an Emacs buffer named `*List Options*'.  Each option is shown with its
  660. documentation and its current value.  Here is what a portion of it might
  661. look like:
  662.  
  663.      ;; exec-path:
  664.      ("." "/usr/local/bin" "/usr/ucb" "/bin" "/usr/bin" "/u2/emacs/etc")
  665.      *List of directories to search programs to run in subprocesses.
  666.      Each element is a string (directory name)
  667.      or nil (try the default directory).
  668.      ;;
  669.      ;; fill-column:
  670.      75
  671.      *Column beyond which automatic line-wrapping should happen.
  672.      Automatically becomes local when set in any fashion.
  673.      ;;
  674.  
  675.    `M-x edit-options' goes one step further and immediately selects the
  676. `*List Options*' buffer; this buffer uses the major mode Options mode,
  677. which provides commands that allow you to point at an option and change
  678. its value:
  679.  
  680. `s'
  681.      Set the variable point is in or near to a new value read using the
  682.      minibuffer.
  683.  
  684. `x'
  685.      Toggle the variable point is in or near: if the value was `nil',
  686.      it becomes `t'; otherwise it becomes `nil'.
  687.  
  688. `1'
  689.      Set the variable point is in or near to `t'.
  690.  
  691. `0'
  692.      Set the variable point is in or near to `nil'.
  693.  
  694. `n'
  695. `p'
  696.      Move to the next or previous variable.
  697.  
  698. 
  699. File: xemacs.info,  Node: Locals,  Next: File Variables,  Prev: Edit Options,  Up: Variables
  700.  
  701. Local Variables
  702. ---------------
  703.  
  704. `M-x make-local-variable'
  705.      Make a variable have a local value in the current buffer.
  706.  
  707. `M-x kill-local-variable'
  708.      Make a variable use its global value in the current buffer.
  709.  
  710. `M-x make-variable-buffer-local'
  711.      Mark a variable so that setting it will make it local to the
  712.      buffer that is current at that time.
  713.  
  714.    You can make any variable "local" to a specific Emacs buffer.  This
  715. means that the variable's value in that buffer is independent of its
  716. value in other buffers.  A few variables are always local in every
  717. buffer.  All other Emacs variables have a "global" value which is in
  718. effect in all buffers that have not made the variable local.
  719.  
  720.    Major modes always make the variables they set local to the buffer.
  721. This is why changing major modes in one buffer has no effect on other
  722. buffers.
  723.  
  724.    `M-x make-local-variable' reads the name of a variable and makes it
  725. local to the current buffer.  Further changes in this buffer will not
  726. affect others, and changes in the global value will not affect this
  727. buffer.
  728.  
  729.    `M-x make-variable-buffer-local' reads the name of a variable and
  730. changes the future behavior of the variable so that it automatically
  731. becomes local when it is set.  More precisely, once you have marked a
  732. variable in this way, the usual ways of setting the variable will
  733. automatically invoke `make-local-variable' first.  We call such
  734. variables "per-buffer" variables.
  735.  
  736.    Some important variables have been marked per-buffer already.  They
  737. include `abbrev-mode', `auto-fill-function', `case-fold-search',
  738. `comment-column', `ctl-arrow', `fill-column', `fill-prefix',
  739. `indent-tabs-mode', `left-margin',
  740. `mode-line-format', `overwrite-mode', `selective-display-ellipses',
  741. `selective-display', `tab-width', and `truncate-lines'.  Some other
  742. variables are always local in every buffer, but they are used for
  743. internal purposes.
  744.  
  745.    Note: the variable `auto-fill-function' was formerly named
  746. `auto-fill-hook'.
  747.  
  748.    If you want a variable to cease to be local to the current buffer,
  749. call `M-x kill-local-variable' and provide the name of a variable to
  750. the prompt.  The global value of the variable is again in effect in
  751. this buffer.  Setting the major mode kills all the local variables of
  752. the buffer.
  753.  
  754.    To set the global value of a variable, regardless of whether the
  755. variable has a local value in the current buffer, you can use the Lisp
  756. function `setq-default'.  It works like `setq'.  If there is a local
  757. value in the current buffer, the local value is not affected by
  758. `setq-default'; thus, the new global value may not be visible until you
  759. switch to another buffer, as in the case of:
  760.  
  761.      (setq-default fill-column 75)
  762.  
  763. `setq-default' is the only way to set the global value of a variable
  764. that has been marked with `make-variable-buffer-local'.
  765.  
  766.    Programs can look at a variable's default value with `default-value'.
  767. This function takes a symbol as an argument and returns its default
  768. value.  The argument is evaluated; usually you must quote it
  769. explicitly, as in the case of:
  770.  
  771.      (default-value 'fill-column)
  772.  
  773. 
  774. File: xemacs.info,  Node: File Variables,  Prev: Locals,  Up: Variables
  775.  
  776. Local Variables in Files
  777. ------------------------
  778.  
  779.    A file can contain a "local variables list", which specifies the
  780. values to use for certain Emacs variables when that file is edited.
  781. Visiting the file checks for a local variables list and makes each
  782. variable in the list local to the buffer in which the file is visited,
  783. with the value specified in the file.
  784.  
  785.    A local variables list goes near the end of the file, in the last
  786. page.  (It is often best to put it on a page by itself.)  The local
  787. variables list starts with a line containing the string `Local
  788. Variables:', and ends with a line containing the string `End:'.  In
  789. between come the variable names and values, one set per line, as
  790. `VARIABLE: VALUE'.  The VALUEs are not evaluated; they are used
  791. literally.
  792.  
  793.    The line which starts the local variables list does not have to say
  794. just `Local Variables:'.  If there is other text before `Local
  795. Variables:', that text is called the "prefix", and if there is other
  796. text after, that is called the "suffix".  If a prefix or suffix are
  797. present, each entry in the local variables list should have the prefix
  798. before it and the suffix after it.  This includes the `End:' line.  The
  799. prefix and suffix are included to disguise the local variables list as
  800. a comment so the compiler or text formatter  will ignore it.  If you do
  801. not need to disguise the local variables list as a comment in this way,
  802. there is no need to include a prefix or a suffix.
  803.  
  804.    Two "variable" names are special in a local variables list: a value
  805. for the variable `mode' sets the major mode, and a value for the
  806. variable `eval' is simply evaluated as an expression and the value is
  807. ignored.  These are not real variables; setting them in any other
  808. context does not have the same effect.  If `mode' is used in a local
  809. variables list, it should be the first entry in the list.
  810.  
  811.    Here is an example of a local variables list:
  812.      ;;; Local Variables: ***
  813.      ;;; mode:lisp ***
  814.      ;;; comment-column:0 ***
  815.      ;;; comment-start: ";;; "  ***
  816.      ;;; comment-end:"***" ***
  817.      ;;; End: ***
  818.  
  819.    Note that the prefix is `;;; ' and the suffix is ` ***'.  Note also
  820. that comments in the file begin with and end with the same strings.
  821. Presumably the file contains code in a language which is enough like
  822. Lisp for Lisp mode to be useful but in which comments start and end
  823. differently.  The prefix and suffix are used in the local variables
  824. list to make the list look like several lines of comments when the
  825. compiler or interpreter for that language reads the file.
  826.  
  827.    The start of the local variables list must be no more than 3000
  828. characters from the end of the file, and must be in the last page if the
  829. file is divided into pages.  Otherwise, Emacs will not notice it is
  830. there.  The purpose is twofold: a stray `Local Variables:' not in the
  831. last page does not confuse Emacs, and Emacs never needs to search a
  832. long file that contains no page markers and has no local variables list.
  833.  
  834.    You may be tempted to turn on Auto Fill mode with a local variable
  835. list.  That is inappropriate.  Whether you use Auto Fill mode or not is
  836. a matter of personal taste, not a matter of the contents of particular
  837. files.  If you want to use Auto Fill, set up major mode hooks with your
  838. `.emacs' file to turn it on (when appropriate) for you alone (*note
  839. Init File::.).  Don't try to use a local variable list that would
  840. impose your taste on everyone working with the file.
  841.  
  842.    XEmacs allows you to specify local variables in the first line of a
  843. file, in addition to specifying them in the `Local Variables' section
  844. at the end of a file.
  845.  
  846.    If the first line of a file contains two occurences of ``-*-'', Emacs
  847. uses the information between them to determine what the major mode and
  848. variable settings should be.  For example, these are all legal:
  849.  
  850.          ;;; -*- mode: emacs-lisp -*-
  851.          ;;; -*- mode: postscript; version-control: never -*-
  852.          ;;; -*- tags-file-name: "/foo/bar/TAGS" -*-
  853.  
  854.    For historical reasons, the syntax ``-*- modename -*-'' is allowed
  855. as well; for example, you can use:
  856.  
  857.          ;;; -*- emacs-lisp -*-
  858.  
  859.    The variable `enable-local-variables' controls the use of local
  860. variables lists in files you visit.  The value can be `t', `nil', or
  861. something else.  A value of `t' means local variables lists are obeyed;
  862. `nil' means they are ignored; anything else means query.
  863.  
  864.    The command `M-x normal-mode' always obeys local variables lists and
  865. ignores this variable.
  866.  
  867. 
  868. File: xemacs.info,  Node: Keyboard Macros,  Next: Key Bindings,  Prev: Variables,  Up: Customization
  869.  
  870. Keyboard Macros
  871. ===============
  872.  
  873.    A "keyboard macro" is a command defined by the user to abbreviate a
  874. sequence of keys.  For example, if you discover that you are about to
  875. type `C-n C-d' forty times, you can speed your work by defining a
  876. keyboard macro to invoke `C-n C-d' and calling it with a repeat count
  877. of forty.
  878.  
  879. `C-x ('
  880.      Start defining a keyboard macro (`start-kbd-macro').
  881.  
  882. `C-x )'
  883.      End the definition of a keyboard macro (`end-kbd-macro').
  884.  
  885. `C-x e'
  886.      Execute the most recent keyboard macro (`call-last-kbd-macro').
  887.  
  888. `C-u C-x ('
  889.      Re-execute last keyboard macro, then add more keys to its
  890.      definition.
  891.  
  892. `C-x q'
  893.      When this point is reached during macro execution, ask for
  894.      confirmation (`kbd-macro-query').
  895.  
  896. `M-x name-last-kbd-macro'
  897.      Give a command name (for the duration of the session) to the most
  898.      recently defined keyboard macro.
  899.  
  900. `M-x insert-kbd-macro'
  901.      Insert in the buffer a keyboard macro's definition, as Lisp code.
  902.  
  903.    Keyboard macros differ from other Emacs commands in that they are
  904. written in the Emacs command language rather than in Lisp.  This makes
  905. it easier for the novice to write them and makes them more convenient as
  906. temporary hacks.  However, the Emacs command language is not powerful
  907. enough as a programming language to be useful for writing anything
  908. general or complex.  For such things, Lisp must be used.
  909.  
  910.    You define a keyboard macro by executing the commands which are its
  911. definition.  Put differently, as you are defining a keyboard macro, the
  912. definition is being executed for the first time.  This way, you see
  913. what the effects of your commands are, and don't have to figure them
  914. out in your head.  When you are finished, the keyboard macro is defined
  915. and also has been executed once.  You can then execute the same set of
  916. commands again by invoking the macro.
  917.  
  918. * Menu:
  919.  
  920. * Basic Kbd Macro::     Defining and running keyboard macros.
  921. * Save Kbd Macro::      Giving keyboard macros names; saving them in files.
  922. * Kbd Macro Query::     Keyboard macros that do different things each use.
  923.  
  924. 
  925. File: xemacs.info,  Node: Basic Kbd Macro,  Next: Save Kbd Macro,  Up: Keyboard Macros
  926.  
  927. Basic Use
  928. ---------
  929.  
  930.    To start defining a keyboard macro, type `C-x ('
  931. (`start-kbd-macro').  From then on, anything you type continues to be
  932. executed, but also becomes part of the definition of the macro.  `Def'
  933. appears in the mode line to remind you of what is going on.  When you
  934. are finished, the `C-x )' command (`end-kbd-macro') terminates the
  935. definition, without becoming part of it.
  936.  
  937.    For example,
  938.  
  939.      C-x ( M-f foo C-x )
  940.  
  941. defines a macro to move forward a word and then insert `foo'.
  942.  
  943.    You can give `C-x )' a repeat count as an argument, in which case it
  944. repeats the macro that many times right after defining it, but defining
  945. the macro counts as the first repetition (since it is executed as you
  946. define it).  If you give `C-x )' an argument of 4, it executes the
  947. macro immediately 3 additional times.  An argument of zero to `C-x e'
  948. or `C-x )' means repeat the macro indefinitely (until it gets an error
  949. or you type `C-g').
  950.  
  951.    Once you have defined a macro, you can invoke it again with the `C-x
  952. e' command (`call-last-kbd-macro').  You can give the command a repeat
  953. count numeric argument to execute the macro many times.
  954.  
  955.    To repeat an operation at regularly spaced places in the text,
  956. define a macro and include as part of the macro the commands to move to
  957. the next place you want to use it.  For example, if you want to change
  958. each line, you should position point at the start of a line, and define
  959. a macro to change that line and leave point at the start of the next
  960. line.  Repeating the macro will then operate on successive lines.
  961.  
  962.    After you have terminated the definition of a keyboard macro, you
  963. can add to the end of its definition by typing `C-u C-x ('.  This is
  964. equivalent to plain `C-x (' followed by retyping the whole definition
  965. so far.  As a consequence it re-executes the macro as previously
  966. defined.
  967.  
  968. 
  969. File: xemacs.info,  Node: Save Kbd Macro,  Next: Kbd Macro Query,  Prev: Basic Kbd Macro,  Up: Keyboard Macros
  970.  
  971. Naming and Saving Keyboard Macros
  972. ---------------------------------
  973.  
  974.    To save a keyboard macro for longer than until you define the next
  975. one, you must give it a name using `M-x name-last-kbd-macro'.  This
  976. reads a name as an argument using the minibuffer and defines that name
  977. to execute the macro.  The macro name is a Lisp symbol, and defining it
  978. in this way makes it a valid command name for calling with `M-x' or for
  979. binding a key to with `global-set-key' (*note Keymaps::.).  If you
  980. specify a name that has a prior definition other than another keyboard
  981. macro, Emacs prints an error message and nothing is changed.
  982.  
  983.    Once a macro has a command name, you can save its definition in a
  984. file.  You can then use it in another editing session.  First visit the
  985. file you want to save the definition in.  Then use the command:
  986.  
  987.      M-x insert-kbd-macro RET MACRONAME RET
  988.  
  989. This inserts some Lisp code that, when executed later, will define the
  990. same macro with the same definition it has now.  You need not
  991. understand Lisp code to do this, because `insert-kbd-macro' writes the
  992. Lisp code for you.  Then save the file.  You can load the file with
  993. `load-file' (*note Lisp Libraries::.).  If the file you save in is your
  994. initialization file `~/.emacs' (*note Init File::.), then the macro
  995. will be defined each time you run Emacs.
  996.  
  997.    If you give `insert-kbd-macro' a prefix argument, it creates
  998. additional Lisp code to record the keys (if any) that you have bound to
  999. the keyboard macro, so that the macro is reassigned the same keys when
  1000. you load the file.
  1001.  
  1002. 
  1003. File: xemacs.info,  Node: Kbd Macro Query,  Prev: Save Kbd Macro,  Up: Keyboard Macros
  1004.  
  1005. Executing Macros With Variations
  1006. --------------------------------
  1007.  
  1008.    You can use `C-x q' (`kbd-macro-query'), to get an effect similar to
  1009. that of `query-replace'.  The macro asks you  each time whether to make
  1010. a change.  When you are defining the macro, type `C-x q' at the point
  1011. where you want the query to occur.  During macro definition, the `C-x
  1012. q' does nothing, but when you invoke the macro, `C-x q' reads a
  1013. character from the terminal to decide whether to continue.
  1014.  
  1015.    The special answers to a `C-x q' query are SPC, DEL, `C-d', `C-l',
  1016. and `C-r'.  Any other character terminates execution of the keyboard
  1017. macro and is then read as a command.  SPC means to continue.  DEL means
  1018. to skip the remainder of this repetition of the macro, starting again
  1019. from the beginning in the next repetition.  `C-d' means to skip the
  1020. remainder of this repetition and cancel further repetition.  `C-l'
  1021. redraws the frame and asks you again for a character to specify what to
  1022. do.  `C-r' enters a recursive editing level, in which you can perform
  1023. editing that is not part of the macro.  When you exit the recursive
  1024. edit using `C-M-c', you are asked again how to continue with the
  1025. keyboard macro.  If you type a SPC at this time, the rest of the macro
  1026. definition is executed.  It is up to you to leave point and the text in
  1027. a state such that the rest of the macro will do what you want.
  1028.  
  1029.    `C-u C-x q', which is `C-x q' with a numeric argument, performs a
  1030. different function.  It enters a recursive edit reading input from the
  1031. keyboard, both when you type it during the definition of the macro and
  1032. when it is executed from the macro.  During definition, the editing you
  1033. do inside the recursive edit does not become part of the macro.  During
  1034. macro execution, the recursive edit gives you a chance to do some
  1035. particularized editing.  *Note Recursive Edit::.
  1036.  
  1037. 
  1038. File: xemacs.info,  Node: Key Bindings,  Next: Syntax,  Prev: Keyboard Macros,  Up: Customization
  1039.  
  1040. Customizing Key Bindings
  1041. ========================
  1042.  
  1043.    This section deals with the "keymaps" that define the bindings
  1044. between keys and functions, and shows how you can customize these
  1045. bindings.
  1046.  
  1047.    A command is a Lisp function whose definition provides for
  1048. interactive use.  Like every Lisp function, a command has a function
  1049. name, which is a Lisp symbol whose name usually consists of lower case
  1050. letters and hyphens.
  1051.  
  1052. * Menu:
  1053.  
  1054. * Keymaps::    Definition of the keymap data structure.
  1055.                Names of Emacs's standard keymaps.
  1056. * Rebinding::  How to redefine one key's meaning conveniently.
  1057. * Disabling::  Disabling a command means confirmation is required
  1058.                 before it can be executed.  This is done to protect
  1059.                 beginners from surprises.
  1060.  
  1061. 
  1062. File: xemacs.info,  Node: Keymaps,  Next: Rebinding,  Up: Key Bindings
  1063.  
  1064. Keymaps
  1065. -------
  1066.  
  1067.    The bindings between characters and command functions are recorded in
  1068. data structures called "keymaps".  Emacs has many of these.  One, the
  1069. "global" keymap, defines the meanings of the single-character keys that
  1070. are defined regardless of major mode.  It is the value of the variable
  1071. `global-map'.
  1072.  
  1073.    Each major mode has another keymap, its "local keymap", which
  1074. contains overriding definitions for the single-character keys that are
  1075. redefined in that mode.  Each buffer records which local keymap is
  1076. installed for it at any time, and the current buffer's local keymap is
  1077. the only one that directly affects command execution.  The local keymaps
  1078. for Lisp mode, C mode, and many other major modes always exist even when
  1079. not in use.  They are the values of the variables `lisp-mode-map',
  1080. `c-mode-map', and so on.  For less frequently used major modes, the
  1081. local keymap is sometimes constructed only when the mode is used for the
  1082. first time in a session, to save space.
  1083.  
  1084.    There are local keymaps for the minibuffer, too; they contain various
  1085. completion and exit commands.
  1086.  
  1087.    * `minibuffer-local-map' is used for ordinary input (no completion).
  1088.  
  1089.    * `minibuffer-local-ns-map' is similar, except that SPC exits just
  1090.      like RET.  This is used mainly for Mocklisp compatibility.
  1091.  
  1092.    * `minibuffer-local-completion-map' is for permissive completion.
  1093.  
  1094.    * `minibuffer-local-must-match-map' is for strict completion and for
  1095.      cautious completion.
  1096.  
  1097.    * `repeat-complex-command-map' is for use in `C-x ESC'.
  1098.  
  1099.    * `isearch-mode-map' contains the bindings of the special keys which
  1100.      are bound in the pseudo-mode entered with `C-s' and `C-r'.
  1101.  
  1102.    Finally, each prefix key has a keymap which defines the key sequences
  1103. that start with it.  For example, `ctl-x-map' is the keymap used for
  1104. characters following a `C-x'.
  1105.  
  1106.    * `ctl-x-map' is the variable name for the map used for characters
  1107.      that follow `C-x'.
  1108.  
  1109.    * `help-map' is used for characters that follow `C-h'.
  1110.  
  1111.    * `esc-map' is for characters that follow ESC. All Meta characters
  1112.      are actually defined by this map.
  1113.  
  1114.    * `ctl-x-4-map' is for characters that follow `C-x 4'.
  1115.  
  1116.    * `mode-specific-map' is for characters that follow `C-c'.
  1117.  
  1118.    The definition of a prefix key is the keymap to use for looking up
  1119. the following character.  Sometimes the definition is actually a Lisp
  1120. symbol whose function definition is the following character keymap.  The
  1121. effect is the same, but it provides a command name for the prefix key
  1122. that you can use as a description of what the prefix key is for.  Thus
  1123. the binding of `C-x' is the symbol `Ctl-X-Prefix', whose function
  1124. definition is the keymap for `C-x' commands, the value of `ctl-x-map'.
  1125.  
  1126.    Prefix key definitions can appear in either the global map or a
  1127. local map.  The definitions of `C-c', `C-x', `C-h', and ESC as prefix
  1128. keys appear in the global map, so these prefix keys are always
  1129. available.  Major modes can locally redefine a key as a prefix by
  1130. putting a prefix key definition for it in the local map.
  1131.  
  1132.    A mode can also put a prefix definition of a global prefix character
  1133. such as `C-x' into its local map.  This is how major modes override the
  1134. definitions of certain keys that start with `C-x'.  This case is
  1135. special, because the local definition does not entirely replace the
  1136. global one.  When both the global and local definitions of a key are
  1137. other keymaps, the next character is looked up in both keymaps, with
  1138. the local definition overriding the global one.  The character after the
  1139. `C-x' is looked up in both the major mode's own keymap for redefined
  1140. `C-x' commands and in `ctl-x-map'.  If the major mode's own keymap for
  1141. `C-x' commands contains `nil', the definition from the global keymap
  1142. for `C-x' commands is used.
  1143.  
  1144. 
  1145. File: xemacs.info,  Node: Rebinding,  Next: Disabling,  Prev: Keymaps,  Up: Key Bindings
  1146.  
  1147. Changing Key Bindings
  1148. ---------------------
  1149.  
  1150.    You can redefine an Emacs key by changing its entry in a keymap.
  1151. You can change the global keymap, in which case the change is effective
  1152. in all major modes except those that have their own overriding local
  1153. definitions for the same key.  Or you can change the current buffer's
  1154. local map, which affects all buffers using the same major mode.
  1155.  
  1156. * Menu:
  1157.  
  1158. * Interactive Rebinding::     Changing Key Bindings Interactively
  1159. * Programmatic Rebinding::    Changing Key Bindings Programmatically
  1160. * Key Bindings Using Strings::Using Strings for Changing Key Bindings
  1161.  
  1162. 
  1163. File: xemacs.info,  Node: Interactive Rebinding,  Next: Programmatic Rebinding,  Up: Rebinding
  1164.  
  1165. Changing Key Bindings Interactively
  1166. ...................................
  1167.  
  1168. `M-x global-set-key RET KEY CMD RET'
  1169.      Defines KEY globally to run CMD.
  1170.  
  1171. `M-x local-set-key RET KEYS CMD RET'
  1172.      Defines KEY locally (in the major mode now in effect) to run CMD.
  1173.  
  1174. `M-x local-unset-key RET KEYS RET'
  1175.      Removes the local binding of KEY.
  1176.  
  1177.    CMD is a symbol naming an interactively-callable function.
  1178.  
  1179.    When called interactively, KEY is the next complete key sequence
  1180. that you type.  When called as a function, KEY is a string, a vector of
  1181. events, or a vector of key-description lists as described in the
  1182. `define-key' function description.  The binding goes in the current
  1183. buffer's local map, which is shared with other buffers in the same
  1184. major mode.
  1185.  
  1186.    The following example:
  1187.  
  1188.      M-x global-set-key RET C-f next-line RET
  1189.  
  1190. redefines `C-f' to move down a line.  The fact that CMD is read second
  1191. makes it serve as a kind of confirmation for KEY.
  1192.  
  1193.    These functions offer no way to specify a particular prefix keymap as
  1194. the one to redefine in, but that is not necessary, as you can include
  1195. prefixes in KEY.  KEY is read by reading characters one by one until
  1196. they amount to a complete key (that is, not a prefix key).  Thus, if
  1197. you type `C-f' for KEY, Emacs enters the minibuffer immediately to read
  1198. CMD.  But if you type `C-x', another character is read; if that
  1199. character is `4', another character is read, and so on.  For example,
  1200.  
  1201.      M-x global-set-key RET C-x 4 $ spell-other-window RET
  1202.  
  1203. redefines `C-x 4 $' to run the (fictitious) command
  1204. `spell-other-window'.
  1205.  
  1206.    The most general way to modify a keymap is the function
  1207. `define-key', used in Lisp code (such as your `.emacs' file).
  1208. `define-key' takes three arguments: the keymap, the key to modify in
  1209. it, and the new definition.  *Note Init File::, for an example.
  1210. `substitute-key-definition' is used similarly; it takes three
  1211. arguments, an old definition, a new definition, and a keymap, and
  1212. redefines in that keymap all keys that were previously defined with the
  1213. old definition to have the new definition instead.
  1214.  
  1215.